package com.hqyj.nacosdemo.provider.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hqyj.nacosdemo.provider.domain.Goods;
import com.hqyj.nacosdemo.provider.mapper.GoodsMapper;
import com.hqyj.nacosdemo.provider.service.GoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {

    @Resource
    private GoodsMapper goodsMapper;
    @Override
    public List<Goods> queryGoodsListByCatalog(String catalog) {

        QueryWrapper<Goods> queryWrapper = null;
        if(!"all".equals(catalog)){
            queryWrapper = new QueryWrapper<Goods>();
            //查询所有的商品
            queryWrapper.eq("catalog",catalog);
        }

        return goodsMapper.selectList(queryWrapper);
    }
}
